package com.company.threads;

/**
 * 匿名类线程
 *
 * @author xiaohutu
 * @return {@link {@link null}}
 * @throws RuntimeException e
 * @data 2021/1/15 10:04
 */
public class ThreadC {
    public long getCount() {
        return count;
    }

    private long count = 0;

    public void add(long value) {
        this.count = this.count + value;
    }

    public static void main(String[] args) {
       /* Runnable runnable = () -> System.out.println("start");
        Thread thread = new Thread(runnable);
        thread.start();
        Thread inner_class = new Thread(() -> System.out.println("new thnread inner class"));
        inner_class.start();*/

        Runnable runnable1 = () -> {
            ThreadC threadC = new ThreadC();
            threadC.add(2);
            System.out.println(threadC.getCount());
        };
        Runnable runnable2 = () -> {
            ThreadC threadC = new ThreadC();
            threadC.add(3);
            System.out.println(threadC.getCount());
        };
        new Thread(runnable1, "thread1").start();
        new Thread(runnable2, "thread2").start();

//        System.out.println(new ThreadC().getCount());
    }
}
